from math import ceil
   
limit = 1000 * 1000
start = (3, 7)

mindiff = 1

for d in range(1, limit + 1):   
    n = 3 * d // 7
    diff = 3 * 1.0 /7 - n * 1.0 / d
    if 0 == diff: continue
    
    if diff < mindiff:
        mindiff = diff
        min = (n, d)
        
print "Done: ", min
